package com.twotwoshop.service.search.controller;

import com.twotwoshop.domin.common.dtos.ResponseResult;
import com.twotwoshop.domin.goods.dtos.GoodsSearchDto;
import com.twotwoshop.domin.search.HistorySearchDto;
import com.twotwoshop.service.search.service.GoodsHistoryService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@RestController
@Slf4j
@RequestMapping("/search/history")
@RequiredArgsConstructor
public class GoodsHistoryController {

    private final GoodsHistoryService goodsHistoryService;

    /**
     *
     * 查询搜索历史
     *
     * @param
     * @return
     */
    @PostMapping("/list")
    public ResponseResult search(){

        log.info("查询搜索历史...{}");

        return goodsHistoryService.findUserSearch();
    }

    /**
     *  删除搜索历史
     *
     * @return historySearchDto
     */
    @PostMapping("/delete")
    public ResponseResult deleteUserSearch(@RequestBody HistorySearchDto historySearchDto){

        log.info("删除搜索历史,{}",historySearchDto);

        return goodsHistoryService.removeUserSearch(historySearchDto);
    }


}
